/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

import { DefaultSyncTask, hvigorCore, Project } from '@ohos/hvigor';
import { defaultModelRegistry } from '@ohos/hvigor';

import { TaskNames } from '../common/task-names.js';

import { OhosProjectModelBean } from './ide/ohos-project-model-bean.js';
import CommonTask = TaskNames.CommonTask;

/**
 * Project级别的Sync任务
 *
 * @since 2022/2/19
 */
export class SyncProject extends DefaultSyncTask {
  constructor(project: Project, taskName: string) {
    super(project, taskName);
    hvigorCore.versionChanged() && this.dependsOn(CommonTask.CLEAN.name);
  }

  registryAction = (): Function => {
    return () => {
      const ohosProjectModelBean = new OhosProjectModelBean(this.node as Project);
      defaultModelRegistry.registry(ohosProjectModelBean);
    };
  };
}
